package com.xiaolin.Thread.pool;

import java.util.concurrent.*;

/**
 * @ClassName NewScheduledThreadPoolTest
 * @Description 可执行延时或者周期性任务的线程池
 * @Detail detail
 * @Author MyPC
 * @Date 2020/12/1
 * @Version 1.0
 */
public class NewScheduledThreadPoolTest {
    public static void main(String[] args) {
        ExecutorService service = getNew3();
        service.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello");
            }
        });
        service.shutdown();
    }

//    public static ExecutorService getNew1(){
//        return new ThreadPoolExecutor(10,Integer.MAX_VALUE,0,TimeUnit.MINUTES,new LinkedBlockingDeque<>());
//    }

//    public static ExecutorService getNew2(){
//        return new ThreadPoolExecutor(10,Integer.MAX_VALUE,0,TimeUnit.MINUTES,new LinkedBlockingDeque<>());
//    }

    /**
     * 第三种方式
     * @return
     */
    public static ExecutorService getNew3(){
        return Executors.newScheduledThreadPool(10);
    }

    /**
     * 第四种方式
     * @return
     */
    public static ExecutorService getNew4(){
        return Executors.newScheduledThreadPool(10,Executors.defaultThreadFactory());
    }
}
